# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     emergency_spectaculars_judge.py
   Description :
   Author :        ZhangYiLin
   date：          2020/12/16 14:06
-------------------------------------------------
   Change Activity:
                   2020/12/16 14:06
-------------------------------------------------
"""
from selenium.webdriver.common.by import By

from common.BasePage import BasePage


class EmergencySpectacularsJudge(BasePage):

    EmergencySupportUnit = (
        By.CSS_SELECTOR,
        "img.cursor:nth-child(1)")  # 保证单位选择框
    ChooseAGuaranteeUnit = (  # 选择保障单位
        By.CSS_SELECTOR,
        ".el-tree > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > label:nth-child(2) > span:nth-child(1) > span:nth-child(1)")
    ConfirmGuaranteeUnit = (By.CSS_SELECTOR, ".btnItem")  # 确认保障单位

    FirstLevelGuarantee = (  # 一级保障
        By.CSS_SELECTOR,
        "label.is-checked > span:nth-child(2)")

    NextStep = (  # 下一步
        By.XPATH,
        "/html/body/div/div[1]/div[2]/div[3]/div[3]/button[2]/span")

    def logistic_emergency_support_research_and_judgment(self):
        self.choose_unit()
        self.choose_guarantee()
        self.next_step()

    def choose_unit(self):
        """
        选择单位
        """
        self.click_emergency_supportUnit()
        self.choose_guarantee_unit()
        self.confirm_guarantee_unit()

    def click_emergency_supportUnit(self):
        """
        打开保证单位选择框
        """
        self.click(*self.EmergencySupportUnit)

    def choose_guarantee_unit(self):
        """
        选择保障单位
        """
        self.click(*self.ChooseAGuaranteeUnit)

    def confirm_guarantee_unit(self):
        """
        确认保障单位
        """
        self.click(*self.ConfirmGuaranteeUnit)

    def choose_guarantee(self):
        """
        选择保障级别
        """
        self.click(*self.FirstLevelGuarantee)

    def next_step(self):
        """
        点击下一步
        """
        self.click(*self.NextStep)